package com.bole.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;


@Configuration
public class MyFreemarkerConfig {

    @Value("${freemarker.templateLoaderPath}")
    private String templateLoaderPath;

    @Value("${freemarker.defaultEncoding}")
    private String defaultEncoding;

    @Bean
    public FreeMarkerConfigurer freeMarkerConfigurer(){
        FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer();
        //设置freemarker模板所在的路径
        freeMarkerConfigurer.setTemplateLoaderPath(templateLoaderPath);
        //设置编码
        freeMarkerConfigurer.setDefaultEncoding(defaultEncoding);
        return freeMarkerConfigurer;
    }
}
